package com.esms.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.esms.dao.EmployeeMapper;
import com.esms.dao.SevaluationMapper;
import com.esms.po.Employee;
import com.esms.po.Sassessment;
import com.esms.po.Sevaluation;
import com.esms.service.IEmployeeSevaluationServer;

@Service
public class EmployeeSevaluationServerImpl implements IEmployeeSevaluationServer {
	@Autowired
    private SevaluationMapper sevaluationMapper = null;
	@Autowired
    private EmployeeMapper employeeMapper = null;
	
    @Override
	public List<Sevaluation> getEmployeeSevaluationList(int eId, String fEid,String quarter) {
    	Employee employee = employeeMapper.selectByPrimaryKey(eId);
		String e_level = employee.geteLevel();
		String e_account = employee.geteAccount();
		String e_byzd1 = employee.getE_byzd1();
		if (e_byzd1 == null || "".equals(e_byzd1)) {
			if ("0".equals(fEid)) {
				return sevaluationMapper.selectBypIdAnddId(e_level, e_account,quarter);
			} else {
				return sevaluationMapper.selectBypIdAnddIdAndfEid(e_level, fEid, e_account,quarter);
			}
		} else {
			if ("0".equals(fEid)) {
				return sevaluationMapper.selectBypIdAnddIdDC(e_level, e_account,e_byzd1,quarter);
			} else {
				return sevaluationMapper.selectBypIdAnddIdAndfEidDC(e_level, fEid, e_account,e_byzd1,quarter);
			}
		}
	}
    
    @Override
    public int updateSevaluationList(Sevaluation sevaluation) {
         return  sevaluationMapper.updateBysId(sevaluation); 
    
    }
    
    @Override
    public int deleteSevaluation(String sAuserid , String sDuserid,String quarter) {
         return  sevaluationMapper.deleteSevaluation(sAuserid, sDuserid,quarter);
    
    }
    
    @Override
    public int insertSevaluation(Sassessment sassessment) {
         return  sevaluationMapper.insertSevaluation(sassessment); 
    
    }
}
